#include"Search.hpp"
#include<memory>
static const std::string input = "/home/ubuntu/Lhd/Project/Boost_Search_Engines/data/output/raw.txt";
void PrintDebug(const std::string& in)
{
    search::ElemArray array;
    array.ParseFromString(in);
    std::cout<<"搜索结果如下: "<<std::endl;
    for(int i = 0;i<array.elem_arry_size();i++)
    {
        std::cout<<"--------------------------------"<<std::endl;
        auto elem = array.elem_arry(i);
        std::cout<<"标题: "<<elem.title()<<std::endl;
        std::cout<<"内容: "<<elem.desc()<<std::endl;
        std::cout<<"url:  "<<elem.url()<<std::endl;
        std::cout<<"--------------------------------"<<std::endl;
    }
}
int main()
{
    std::unique_ptr<Searcher> search = std::make_unique<Searcher>();
    search->InitSearch(input);
    while(true)
    {
        std::string query;
        std::string out;
        std::cout<<"Please Enter You Search Query# ";
        std::getline(std::cin,query);
        search->Search(query,&out);
        std::cout<<"---------------------"<<std::endl;
        std::cout<<out<<std::endl;
        //PrintDebug(out);
    }
    return 0;
}